// Copyright 2022 jeff.li. and/or its affiliates.

#include <gtest/gtest.h>
#include <tbir/runtime/container/unicode.h>
#include <tbir/runtime/unicodelib/py_unicodedata.h>
#include <tbir/runtime/utf8_util.h>
#include <iostream>

namespace tbir::runtime {

    TEST(PyUnicodeData, normalize) {
        auto s1 = UTF8Decode("Spicy Jalape\u00f1o");
        auto s2 = UTF8Decode("Spicy Jalapen\u0303o");
        PyUnicodeData unicodedata;
        auto s2_nfc = unicodedata.normalize(UnicodeNormalForm::NFC, s2);
        EXPECT_EQ(s2_nfc, s1);
        auto s1_nfd = unicodedata.normalize(UnicodeNormalForm::NFD, s1);
        EXPECT_EQ(s1_nfd, s2);
    }

    TEST(PyUnicodeData, decimal) {
        PyUnicodeData unicodedata;
        long d = unicodedata.decimal('9');
        EXPECT_EQ(d, 9);
        EXPECT_THROW(unicodedata.decimal('a'), ValueError);
    }

}  // namespace tbir::runtime
